In [12]:
import ipyleaflet as leaflet
import ipywidgets as widgets
import random

In [13]:
def get_random_coordinates():
    lat = random.uniform(-85, 85)
    long = random.uniform(-180, 180)
    return [lat, long]

In [14]:
map1 = leaflet.Map()
map1.center = [52.3807305, 13.063064]
map1.zoom = 17
map1


Challenge 1

Create a button widget, and connect the on_click event in Python to a callback that sets the map's center trait to a coordinate obtained from get_random_coordinates. Also, maybe add some description to your button?

Challenge 2

Create a IntSlider widget, and connect it to the map's zoom attribute! Bonus points if you use link. The value of the IntSlider should lie between the map's min_zoom and max_zoom.

Challenge 3

Put the slider, the button and the map into a VBox.

Documentation

You can find all the ipywidgets and attributes here

Documentation about the widget events

And ipyleaflet's documentation on the Map widget